import {
  defineComponent,
  useCssVars,
  ref,
  computed,
  resolveDirective,
  withDirectives,
  openBlock,
  createElementBlock,
  unref,
  normalizeStyle,
  Fragment,
  renderList,
  createCommentVNode,
  createElementVNode
} from "vue";
import {
  b as useProp,
  j as useData,
  _ as _export_sfc
} from "./index-CEDaTd93.js";
const _hoisted_1 = { class: "dv-scroll-board" };
const _hoisted_2 = ["innerHTML"];
const _hoisted_3 = { class: "rows" };
const _hoisted_4 = ["innerHTML", "title"];
const _sfc_main = /* @__PURE__ */ defineComponent({
  __name: "ScrollTable",
  props: {
    component: {}
  },
  setup(__props) {
    useCssVars(_ctx => ({
      c6f6fb4a: mySpeed.value
    }));
    const tableHeader = ref([]);
    const props = __props;
    const { propValue } = useProp(props.component);
    const mySpeed = computed(() => {
      return propValue.rows.speed + "s";
    });
    const comHeight = ref(0);
    const resizeHandler = entry => {
      const { height } = entry.contentRect;
      comHeight.value = height;
    };
    const tableData = ref([]);
    const dataChange = (resp, _) => {
      if (resp.status === "SUCCESS") {
        tableHeader.value = [];
        Object.keys(resp.afterData[0]).forEach(key => {
          tableHeader.value.push(key);
        });
        tableData.value = resp.afterData;
      }
    };
    useData(props.component, dataChange);
    const rowData = computed(() => {
      return tableData.value.map((item, index) => {
        return {
          rowIndex: index,
          ceils: Object.values(item)
        };
      });
    });
    return (_ctx, _cache) => {
      const _directive_resize = resolveDirective("resize");
      return withDirectives(
        (openBlock(),
        createElementBlock("div", _hoisted_1, [
          unref(propValue).header.isHeader
            ? (openBlock(),
              createElementBlock(
                "div",
                {
                  key: 0,
                  class: "header",
                  style: normalizeStyle(
                    `background-color: ${unref(propValue).header.headerBGC};`
                  )
                },
                [
                  (openBlock(true),
                  createElementBlock(
                    Fragment,
                    null,
                    renderList(tableHeader.value, (item, i) => {
                      return (
                        openBlock(),
                        createElementBlock(
                          "div",
                          {
                            key: `${item}${i}`,
                            class: "header-item",
                            style: normalizeStyle(`
          height: ${unref(propValue).header.headerHeight}px;
          line-height: ${unref(propValue).header.headerHeight}px;
          max-width:${unref(propValue).header.width}px;
          color:${unref(propValue).header.headerColor};
          font-size:${unref(propValue).header.headerSize}px;
         width:100%;
         text-align:left;
        `),
                            innerHTML: item
                          },
                          null,
                          12,
                          _hoisted_2
                        )
                      );
                    }),
                    128
                  ))
                ],
                4
              ))
            : createCommentVNode("", true),
          createElementVNode(
            "div",
            {
              class: "mybody",
              style: normalizeStyle(
                `background-color:${unref(propValue).rows.background}`
              )
            },
            [
              createElementVNode("div", _hoisted_3, [
                (openBlock(true),
                createElementBlock(
                  Fragment,
                  null,
                  renderList(rowData.value, (row, ri) => {
                    return (
                      openBlock(),
                      createElementBlock(
                        "div",
                        {
                          key: row.rowIndex,
                          class: "row-item",
                          style: normalizeStyle(`
          height: ${unref(propValue).rows.data.height}px;
          line-height: ${unref(propValue).rows.data.height}px;
          background-color: ${
            unref(propValue).rows.data[
              row.rowIndex % 2 === 0 ? "evenRowBGC" : "oddRowBGC"
            ]
          };
        `)
                        },
                        [
                          (openBlock(true),
                          createElementBlock(
                            Fragment,
                            null,
                            renderList(row.ceils, (ceil, ci) => {
                              return (
                                openBlock(),
                                createElementBlock(
                                  "div",
                                  {
                                    key: `${ceil}${ri}${ci}`,
                                    class: "ceil",
                                    innerHTML: ceil,
                                    style: normalizeStyle(`
          max-width:${unref(propValue).header.width}px;
          color:${unref(propValue).rows.fontColor};
          font-size:${unref(propValue).rows.fontSize}px;
          width:100%;
          text-align:left;
          `),
                                    title: ceil
                                  },
                                  null,
                                  12,
                                  _hoisted_4
                                )
                              );
                            }),
                            128
                          ))
                        ],
                        4
                      )
                    );
                  }),
                  128
                ))
              ])
            ],
            4
          )
        ])),
        [[_directive_resize, resizeHandler]]
      );
    };
  }
});
const ScrollTable = /* @__PURE__ */ _export_sfc(_sfc_main, [
  ["__scopeId", "data-v-070d2b21"]
]);
export { ScrollTable as default };
